package com.hx.portal.controller.hospital;


import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.hospital.pojo.District;
import com.hx.hospital.service.DistrictService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/district")
@Api(description = "院区相关接口")
public class DistrictController {

    @Reference
    private DistrictService districtService;

    @GetMapping("/findAll")
    public List<District> findAll(){
        return districtService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<District> findPage(int page, int size){
        return districtService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<District> findList(@RequestBody Map<String,Object> searchMap){
        return districtService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<District> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  districtService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public District findById(Long id){
        return districtService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody District district){
        districtService.add(district);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody District district){
        districtService.update(district);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        districtService.delete(id);
        return new Result();
    }

}
